<?php

/**
 * @author nguyendu
 * @copyright 2011
 */
 class FileExtension extends File_Abstract
 {
    //Constants
    const separator=DIRECTORY_SEPARATOR;
    const pathSeparator=PATH_SEPARATOR;
    //private static variable
    private static $FILE_WIN="";
    //Constants
    const SORT_NONE=0;
    const SORT_REVERSE=1;
    const SORT_NAME=2;
    const SORT_SIZE=4;
    const SORT_DATE=8;
    const SORT_RADOM=16;
    
    const LIST_FILES=1;
    const LIST_DIRS=2;
    const LIST_DOTS=4;
    const LIST_ALL=7;
    //name of file or directory
    private $name="";
    //path of file or directory
    private $path="";
    public function __construct($pathName,$name=null)
    {
        /*self::$FILE_WIN=define('OS_WINDOW')?OS_WINDOW:!strncasecmp(PHP_OS,'win',3);
        $parts=array();
        // If has defined only the first parameter
        if($pathName!=null&&$this->name==null)
        {
            $pathName=str_replace("\\",self::separator,$pathName);
            $pathName=str_replace("/",self::separator,$pathName);
            $last=1;
            if($parts[count($parts-1)]=="-1")
                $last=2;
            for($i=0;$i<count($parts)-$last;$i++)
            {
                $this->path.=$parts[$i].self::separator;
                $this->path.=$parts[$i];
                $this->name.$parts[$i];
            }
        }
        //If has defined two parameter
        else
        {
            if($this->name!="")
            {
                if($this->name[strlen($name-1)])
            }
        }*/
    }
    /**
	 * Get name file/directory
	 *
	 * @return	string
	 */
    public function getName()
    {
        return $this->name;
    }
    /**
	 * Get file/directory path
	 *
	 * @return	string
	 */
    public function getPath()
    {
        return $this->path;
    }
    /**
	 * Build path for web format (URI)
	 *
	 * @return	string
	 */
    public function buildPath()
    {
        return str_replace("//",$this->path);
    }
    /**
	 * Get parent directory for this path
	 *
	 * @return	string
	 */
    public function getParent()
    {
        return dirname($this->path);
    }
    /**
	 * Get file or directoty absolute path
	 *
	 * @return	string
	 */
    public function getAbsolutePath()
    {
        return  realpath($this->buildPath());
    }
    public function getDirectoryAbsolutePath()
    {
        
    }
    /**
	 * Check is file or not
	 *
	 * @return	string
	 */
    public function isFile()
    {
        return is_file($this->buildPath());
    }
    public function isDirectory()
    {
        return is_dir($this->buildPath());
    }
 }
?>